class Solution {
    vector<vector<int>> ret;
    vector<int> path;
    bool chick[6] = {false};
    int sz;
public:
    vector<vector<int>> permute(vector<int>& nums) {
        sz = nums.size();
        dfs(nums);
        return ret;
    }

    void dfs(vector<int>& nums)
    {
        if(path.size() == sz)
        {
            ret.push_back(path);
            return;
        }

        for(int i = 0; i < sz; ++i)
        {
            if(chick[i] == false)
            {
                path.push_back(nums[i]);
                chick[i] = true;
                dfs(nums);
                path.pop_back();
                chick[i] = false;
            }
        }
    }
};